In [1]:
try:
from ddexreader import open_ddex, ddex_to_dict
except ImportError:
# If ddexreader has not been installed, add the parent directory
# to the system path
import sys
sys.path.append('..')
from ddexreader import open_ddex, ddex_to_dict
import os
xml_path = os.path.abspath(os.path.join(os.getcwdu(), '..', 'fixtures/ern36.xml'))
print u'Parsing XML file in {0}'.format(xml_path)
ddex = open_ddex(xml_path)
ddex_dict = ddex_to_dict(ddex)
Parsing XML file in /srv/git/ddexreader/fixtures/ern36.xml
In [2]:
# Underlying ddex data structure. Complex, right?
print ddex
print dir(ddex)
<ern36.binding.CTD_ANON object at 0x7f51fc80f3d0>
['BusinessProfileVersionId', 'CatalogTransfer', 'CollectionList', 'CueSheetList', 'DealList', 'Factory', 'IsBackfill', 'LanguageAndScriptCode', 'MessageHeader', 'MessageSchemaVersionId', 'ReleaseList', 'ReleaseProfileVersionId', 'ResourceList', 'UpdateIndicator', 'WorkList', '_Abstract', '_AddElement', '_AlternativeConstructor', '_AttributeMap', '_AttributeWildcard', '_Automaton', '_CTD_ANON__BusinessProfileVersionId', '_CTD_ANON__CatalogTransfer', '_CTD_ANON__CollectionList', '_CTD_ANON__CueSheetList', '_CTD_ANON__DealList', '_CTD_ANON__IsBackfill', '_CTD_ANON__LanguageAndScriptCode', '_CTD_ANON__MessageHeader', '_CTD_ANON__MessageSchemaVersionId', '_CTD_ANON__ReleaseList', '_CTD_ANON__ReleaseProfileVersionId', '_CTD_ANON__ResourceList', '_CTD_ANON__UpdateIndicator', '_CTD_ANON__WorkList', '_CT_ELEMENT_ONLY', '_CT_EMPTY', '_CT_MIXED', '_CT_SIMPLE', '_CompatibleValue', '_ContentTypeTag', '_DynamicCreate', '_DynamicCreate_mixin__AlternativeConstructorAttribute', '_DynamicCreate_mixin__SupersedingClassAttribute', '_ElementBindingDeclForName', '_ElementMap', '_ExpandedName', '_GetValidationConfig', '_HasWildcardElement', '_IsMixed', '_IsSimpleTypeContent', '_IsUrType', '_Locatable_mixin__location', '_Name', '_PerformValidation', '_PreFactory_vx', '_PyXBFactoryKeywords', '_RequireXSIType', '_ReservedSymbols', '_SetAlternativeConstructor', '_SetSupersedingClass', '_SetValidationConfig', '_SupersedingClass', '_TypeBinding_mixin__AttributesFromDOM', '_TypeBinding_mixin__WarnedUnassociatedElement', '_TypeBinding_mixin__checkNilCtor', '_TypeBinding_mixin__constructedWithValue', '_TypeBinding_mixin__element', '_TypeBinding_mixin__getValidationConfig', '_TypeBinding_mixin__namespaceContext', '_TypeBinding_mixin__xsiNil', '_TypeDefinition', '_UseForTag', '_XSDLocation', '__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__', '__hash__', '__httpddex_netxmlern36_CTD_ANON_BusinessProfileVersionId', '__httpddex_netxmlern36_CTD_ANON_CatalogTransfer', '__httpddex_netxmlern36_CTD_ANON_CollectionList', '__httpddex_netxmlern36_CTD_ANON_CueSheetList', '__httpddex_netxmlern36_CTD_ANON_DealList', '__httpddex_netxmlern36_CTD_ANON_IsBackfill', '__httpddex_netxmlern36_CTD_ANON_LanguageAndScriptCode', '__httpddex_netxmlern36_CTD_ANON_MessageHeader', '__httpddex_netxmlern36_CTD_ANON_MessageSchemaVersionId', '__httpddex_netxmlern36_CTD_ANON_ReleaseList', '__httpddex_netxmlern36_CTD_ANON_ReleaseProfileVersionId', '__httpddex_netxmlern36_CTD_ANON_ResourceList', '__httpddex_netxmlern36_CTD_ANON_UpdateIndicator', '__httpddex_netxmlern36_CTD_ANON_WorkList', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_addContent', '_appendWildcardElement', '_automatonConfiguration', '_complexTypeDefinition__NeedWarnOnContent', '_complexTypeDefinition__WarnOnContent', '_complexTypeDefinition__automatonConfiguration', '_complexTypeDefinition__childrenForDOM', '_complexTypeDefinition__content', '_complexTypeDefinition__setContent', '_complexTypeDefinition__wildcardAttributeMap', '_complexTypeDefinition__wildcardElements', '_constructedWithValue', '_description', '_diagnosticName', '_element', '_finalizeContentModel', '_isNil', '_location', '_namespaceContext', '_performValidation', '_postDOMValidate', '_postFactory_vx', '_resetAutomaton', '_resetContent', '_setAttribute', '_setAttributesFromKeywordsAndDOM', '_setDOMFromAttributes', '_setElement', '_setIsNil', '_setLocation', '_setNamespaceContext', '_setValidationConfig', '_setValue', '_substitutesFor', '_symbolSet', '_toDOM_csc', '_validateAttributes', '_validateBinding_vx', '_validatedChildren', '_validationConfig', '_validationConfig_', 'append', 'content', 'extend', 'orderedContent', 'reset', 'toDOM', 'toxml', 'validateBinding', 'value', 'wildcardAttributeMap', 'wildcardElements', 'xsdConstraintsOK']
In [3]:
# Level 1 keys
ddex_dict.keys()
Out[3]:
['CollectionList',
'CatalogTransfer',
'ReleaseList',
'UpdateIndicator',
'ReleaseProfileVersionId',
'BusinessProfileVersionId',
'MessageSchemaVersionId',
'LanguageAndScriptCode',
'MessageHeader',
'ResourceList',
'CueSheetList',
'WorkList',
'IsBackfill',
'DealList']
In [4]:
ddex_dict['MessageSchemaVersionId']
Out[4]:
u'ern/36'
In [5]:
ddex_dict['MessageHeader']
Out[5]:
{'Comment': None,
'LanguageAndScriptCode': None,
'MessageAuditTrail': None,
'MessageControlType': u'TestMessage',
'MessageCreatedDateTime': dateTime(1, 1, 1, 0, 0),
'MessageFileName': u'VideoSingle.ERN33.xml',
'MessageId': u'CBCDCC44-EE59-482b-B3CA-02986E6870EC',
'MessageRecipient': {'LanguageAndScriptCode': None,
'PartyId': [{'IsDPID': None, 'IsISNI': None, 'Namespace_': None}],
'PartyName': None,
'TradingName': u'Lamson Digital Distribution'},
'MessageSender': {'LanguageAndScriptCode': None,
'PartyId': [{'IsDPID': None, 'IsISNI': None, 'Namespace_': None}],
'PartyName': None,
'TradingName': u'Iron Crown Music'},
'MessageThreadId': u'CBCDCC44-EE59-482b-B3CA-02986E6870EC',
'SentOnBehalfOf': None}
In [6]:
ddex_dict['UpdateIndicator']
Out[6]:
u'OriginalMessage'
In [7]:
ddex_dict['ResourceList']
Out[7]:
{'Image': [{'CreationDate': None,
'ImageDetailsByTerritory': [{'CLine': [],
'CourtesyLine': None,
'Description': None,
'ExcludedTerritoryCode': [],
'FulfillmentDate': None,
'Genre': [],
'IndirectResourceContributor': [],
'Keywords': [],
'LanguageAndScriptCode': None,
'OriginalResourceReleaseDate': None,
'ParentalWarningType': [{'Namespace_': None, 'UserDefinedValue': None}],
'ResourceContributor': [],
'Synopsis': None,
'TechnicalImageDetails': [{'AspectRatio': None,
'ColorDepth': None,
'ConsumerFulfillmentDate': None,
'ContainerFormat': None,
'DrmPlatformType': None,
'File': [{'FileName': u'A1UCASE0000000007X_01_01.jpeg',
'FilePath': None,
'HashSum': None,
'URL': None}],
'FileAvailabilityDescription': [],
'Fingerprint': [],
'FulfillmentDate': None,
'ImageCodecType': None,
'ImageHeight': None,
'ImageResolution': None,
'ImageWidth': None,
'IsPreview': None,
'LanguageAndScriptCode': None,
'PreviewDetails': None,
'TechnicalResourceDetailsReference': u'T2'}],
'TerritoryCode': [u'Worldwide']}],
'ImageId': [{'IsReplaced': None,
'ProprietaryId': [{'Namespace_': u'DPID:PADPIDA0000000001A'}]}],
'ImageType': u'VideoScreenCapture',
'IsArtistRelated': None,
'IsUpdated': None,
'LanguageAndScriptCode': None,
'ResourceReference': u'A2',
'Title': []}],
'LanguageAndScriptCode': None,
'MIDI': [],
'SheetMusic': [],
'Software': [],
'SoundRecording': [],
'Text': [],
'UserDefinedResource': [],
'Video': [{'CreationDate': None,
'Duration': duration(0, 1201),
'HasPreOrderFulfillment': None,
'IndirectVideoId': [],
'InstrumentationDescription': None,
'IsArtistRelated': None,
'IsBackground': None,
'IsBonusResource': None,
'IsHiddenResource': None,
'IsInstrumental': None,
'IsMedley': None,
'IsPotpourri': None,
'IsRemastered': None,
'IsUpdated': None,
'LanguageAndScriptCode': None,
'LanguageOfDubbing': [],
'LanguageOfPerformance': [],
'MasteredDate': None,
'NoSilenceAfter': None,
'NoSilenceBefore': None,
'NumberOfContractedArtists': None,
'NumberOfFeaturedArtists': None,
'NumberOfNonContractedArtists': None,
'NumberOfNonFeaturedArtists': None,
'PerformerInformationRequired': None,
'ReasonForCueSheetAbsence': None,
'ReferenceTitle': {'LanguageAndScriptCode': None,
'SubTitle': u'Live at Budokan',
'TitleText': u'Can you feel ...the Monkey Claw!'},
'ResourceContainedResourceReferenceList': None,
'ResourceMusicalWorkReferenceList': None,
'ResourceReference': u'A1',
'RightsAgreementId': None,
'SubTitleLanguage': [],
'TerritoryOfCommissioning': None,
'Title': [],
'VideoCollectionReferenceList': None,
'VideoCueSheetReference': [],
'VideoDetailsByTerritory': [{'AvRating': [],
'CLine': [],
'Character': [],
'CourtesyLine': None,
'DisplayArtist': [{'ArtistRole': [{'Namespace_': None,
'UserDefinedValue': None}],
'PartyId': [],
'PartyName': [{'AbbreviatedName': None,
'FullName': u'Monkey Claw',
'FullNameAsciiTranscribed': None,
'FullNameIndexed': None,
'KeyName': None,
'LanguageAndScriptCode': None,
'NamesAfterKeyName': None,
'NamesBeforeKeyName': None}],
'SequenceNumber': 1L}],
'DisplayConductor': [],
'ExcludedTerritoryCode': [],
'FulfillmentDate': None,
'Genre': [{'GenreText': u'Metal',
'LanguageAndScriptCode': None,
'SubGenre': u'Progressive Metal'}],
'HostSoundCarrier': [],
'IndirectResourceContributor': [],
'Keywords': [],
'LabelName': [],
'LanguageAndScriptCode': None,
'MarketingComment': None,
'OriginalResourceReleaseDate': None,
'PLine': [{'LanguageAndScriptCode': None,
'PLineCompany': None,
'PLineText': u'(P) 2010 Iron Crown Music',
'PLineType': None,
'Year': gYear(2010, 1, 1, 0, 0)}],
'ParentalWarningType': [{'Namespace_': None, 'UserDefinedValue': None}],
'RemasteredDate': None,
'ResourceContributor': [],
'RightsAgreementId': None,
'RightsController': [],
'SequenceNumber': None,
'Synopsis': None,
'TechnicalVideoDetails': [{'AspectRatio': None,
'AudioBitRate': None,
'AudioBitsPerSample': None,
'AudioCodecType': None,
'AudioSamplingRate': None,
'ColorDepth': None,
'ConsumerFulfillmentDate': None,
'ContainerFormat': None,
'DrmPlatformType': None,
'Duration': None,
'File': [{'FileName': u'A1UCASE0000000007X_01_01.mpeg',
'FilePath': None,
'HashSum': None,
'URL': None}],
'FileAvailabilityDescription': [],
'Fingerprint': [],
'FrameRate': None,
'FulfillmentDate': None,
'ImageHeight': None,
'ImageWidth': None,
'IsPreview': None,
'LanguageAndScriptCode': None,
'NumberOfAudioChannels': None,
'OverallBitRate': None,
'PreviewDetails': None,
'ResourceProcessingRequired': None,
'TechnicalResourceDetailsReference': u'T1',
'UsableResourceDuration': None,
'VideoBitRate': None,
'VideoCodecType': None,
'VideoDefinitionType': None}],
'TerritoryCode': [u'Worldwide'],
'Title': [{'LanguageAndScriptCode': None,
'SubTitle': [{'LanguageAndScriptCode': None, 'SubTitleType': None}],
'TitleText': u'Can you feel ...the Monkey Claw!',
'TitleType': u'FormalTitle'},
{'LanguageAndScriptCode': None,
'SubTitle': [],
'TitleText': u'Can you feel ...the Monkey Claw! (Live at Budokan)',
'TitleType': u'DisplayTitle'},
{'LanguageAndScriptCode': u'ja',
'SubTitle': [{'LanguageAndScriptCode': None, 'SubTitleType': None}],
'TitleText': u'\u30ad\u30e3\u30f3\u30fb\u30e6\u30fc\u30fb\u30d5\u30a3\u30fc\u30eb\uff0e\uff0e\uff0e\u30b6\u30fb\u30e2\u30f3\u30ad\u30fc\u30fb\u30af\u30ed\u30fc\uff01',
'TitleType': u'TranslatedTitle'},
{'LanguageAndScriptCode': u'ja-Kana',
'SubTitle': [{'LanguageAndScriptCode': None, 'SubTitleType': None}],
'TitleText': u'\u30ad\u30e3\u30f3\u30fb\u30e6\u30fc\u30fb\u30d5\u30a3\u30fc\u30eb\u2026\u30b6\u30fb\u30e2\u30f3\u30ad\u30fc\u30fb\u30af\u30ed\u30fc! ',
'TitleType': u'TranslatedTitle'}]}],
'VideoId': [{'CatalogNumber': None,
'ISAN': None,
'ISRC': u'CASE00000007',
'IsReplaced': None,
'ProprietaryId': [],
'VISAN': None}],
'VideoType': u'ShortFormMusicalWorkVideo'}]}
Content source: Trax-air/ddexreader
Similar notebooks: